﻿#ifndef CONFIG_H
#define CONFIG_H

#include <QString>
#include <QStringList>
#include <QSettings>
#include <QDir>
#include <string.h>


typedef struct _UI_CONF_VAR{
    char    Title[64];
    int     Start;
    int     MouseWheelStep;
    int     MouseMoveStep;
    int     CameraIndex;
    int     CameraTime;
    int     WindowStatus;
    int     ImageGray;
    int     ImageResolution;
    int     ImageInverse;
    int     ColorSetup;
    int     ImageVertical;
    int     ImageHorizontal;
    int     ImageRotate;
    int     ImageZoom;
    int     ImageZoomMax;
}UI_CONF_VAR;

typedef struct _UI_COLOR_VAR{
    int     WinX;
    int     WinY;
    int     WinWidth;
    int     WinHeight;
    int     ContrastValue;
    int     ContrastMin;
    int     ContrastMax;
    int     BrightnessValue;
    int     BrightnessMin;
    int     BrightnessMax;
    int     SaturationValue;
    int     SaturationMin;
    int     SaturationMax;
    int     GammaValue;
    int     GammaMin;
    int     GammaMax;
}UI_COLOR_VAR;

typedef struct _UI_ENLARGE_VAR{
    int     WinX;
    int     WinY;
    int     WinWidth;
    int     WinHeight;
    float   WinZoom;
}UI_ENLARGE_VAR;

typedef struct _UI_SAVE_VAR{
    char    SavePath[64];
    char    CurDir[32];
}UI_SAVE_VAR;

class Config
{
public:
    Config();
    ~Config();

    void setConfName(const QString name);
    bool readConfig(void);

    QVariant getConfig(const char *set, const char *key);
    QVariant getConfVar(const char *key);
    QVariant getSaveVar(const char *key);
    QVariant getColorVar(const char *key);
    QVariant getEnlargeVar(const char *key);
    QVariant getMenuVar(const char *key);

    void saveCamera(void);
    void saveConfig(void);
    void saveSave(void);
    void saveColor(void);
    void saveEnlarge(void);

public:
    UI_CONF_VAR confVar;
    UI_COLOR_VAR colorVar;
    UI_SAVE_VAR saveVar;
    UI_ENLARGE_VAR enlargeVar;
    QStringList actionList;
    QVector<int> actionType;
    QVector<int> actionMark;

private:
    QSettings *configIni;
    QString confName;
};

#endif // CONFIG_H
